//
//  MoreNewestMusicCollectionViewCell.m
//  LuckyRadio
//
//  Created by Mr、J on 15/11/26.
//  Copyright © 2015年 chenjun. All rights reserved.
//

#import "MoreNewestMusicCollectionViewCell.h"
#import <UIImageView+WebCache.h>

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define WIDTH_PRO(X) (X)*(SCREEN_WIDTH/375)

#define HEIGHT_PRO(Y) (Y)*(SCREEN_HEIGHT/667)
@implementation MoreNewestMusicCollectionViewCell
- (void)dealloc
{
    [_moreNewestModel release];
    [_image release];
    [_titleLabel release];
    [_singerLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.image = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
    
    self.singerLabel = [[UILabel alloc] init];
    self.singerLabel.textColor = [UIColor grayColor];
    self.singerLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.singerLabel];
    [_singerLabel release];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, (SCREEN_WIDTH - WIDTH_PRO(30)) / 2, (SCREEN_WIDTH - WIDTH_PRO(30)) / 2);
    self.titleLabel.frame = CGRectMake(0, self.image.frame.size.height + HEIGHT_PRO(10), self.image.frame.size.width, HEIGHT_PRO(20));
    self.singerLabel.frame = CGRectMake(0, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height, self.titleLabel.frame.size.width, HEIGHT_PRO(20));
}


-(void)setMoreNewestModel:(MoreNewestModel *)moreNewestModel
{
    if (_moreNewestModel != moreNewestModel) {
        [_moreNewestModel release];
        _moreNewestModel = [moreNewestModel retain];
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:moreNewestModel.picUrl] placeholderImage:[UIImage imageNamed:@"Read_zhanwei"]];
    self.titleLabel.text = moreNewestModel.name;
    self.singerLabel.text = moreNewestModel.singerName;
    
    
}



@end
